package com.winz.cultureapp.fragment;

import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.winz.cultureapp.R;
import com.winz.cultureapp.base.BaseFragment;
import com.winz.cultureapp.constants.Constants;

import butterknife.BindView;

/**
 * 非遗概述
 */
public class SummaryFragment extends BaseFragment {

    @BindView(R.id.wv_content)
    WebView mWv_contet;

    public static SummaryFragment getInstance() {

        SummaryFragment fragment = new SummaryFragment();

        return fragment;
    }

    @Override
    protected int contentView() {
        return R.layout.fragment_summary;
    }

    @Override
    protected void initViews(View view) {
        mWv_contet.getSettings().setJavaScriptEnabled(true);//设置WebView支持JS
        mWv_contet.getSettings().setDefaultTextEncodingName("utf-8");//设置解码时的字符集
        mWv_contet.getSettings().setLoadWithOverviewMode(true);
        mWv_contet.getSettings().setUseWideViewPort(true);
        mWv_contet.getSettings().setSupportZoom(true);
        mWv_contet.getSettings().setBuiltInZoomControls(true);
        mWv_contet.getSettings().setDomStorageEnabled(true);
        mWv_contet.getSettings().setBuiltInZoomControls(false);
        mWv_contet.setWebViewClient(new WebViewClient() {
            /*
            此处能拦截超链接的url,即拦截href请求的内容.
            */
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                mWv_contet.loadUrl(url);
//                if (url.startsWith("http")) {
//
////                    // 调用系统默认浏览器处理url
////                    view.stopLoading();
////                    view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
//                    return true;
//                }else {
//                    showMsg("该链接不是http");
//                }
                return true;
            }

        });

        mWv_contet.loadUrl(Constants.URL.IP + "/legacy/summary");
    }


}
